#!/usr/bin/perl -w
use strict;
use warnings;
use DBI;

require('function.pl');
require('config.pl');

my %trans = (
1 => 1,
0 => 2
);

my $db_conn = DBI->connect("DBI:mysql:database=phone_num_search;host=$ENV{'db_host'}", $ENV{'db_user'}, $ENV{'db_password'});
$db_conn->do('set names utf8');
open IN, "data/validated_phone_num" or die("fail	open data/validated_phone_num\n");
while (<IN>) {
	if (/(\d+)\t(\d)/) {
		my ($phone_num, $flag) = ($1, $2);
		my $sql = "update phone_num set vacant_num = $trans{$flag} where phone_num = '$phone_num'";
		print "$flag\t$sql\n";
		$db_conn->do($sql);
	}
}
